﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GLYFrom.GLYGL
{
    public partial class GLY_SeleDele : Form
    {
        public GLY_SeleDele()
        {
            InitializeComponent();
        }

        private void 修改ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(this.dataGrid_YH.SelectedRows[0].Cells["Colu_YHId"].Value);
            GLYGL.GLY_update from = new GLY_update(id);
            from.Show();
        }

        private void GLY_SeleDele_Load(object sender, EventArgs e)
        {
            DataTable table = DBHelper.select("select * from T_GuanLiYuan");
            this.dataGrid_YH.AutoGenerateColumns = false;
            this.dataGrid_YH.DataSource = table;
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要删除吗？","提示",MessageBoxButtons.OKCancel)==DialogResult.Cancel)
            {
                int id = Convert.ToInt32(this.dataGrid_YH.SelectedRows[0].Cells["Colu_YHId"].Value);
                int sr = DBHelper.ZSG(string.Format("delete from T_GuanLiYuan where GLYId='{0}'", id));
                if (sr > 0)
                {
                    MessageBox.Show("删除成功！");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("删除失败！");
                }
            }
        }

        private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataTable table = DBHelper.select("select * from T_GuanLiYuan");
            this.dataGrid_YH.DataSource = null;
            this.dataGrid_YH.DataSource = table;
        }
    }
}
